﻿using Microsoft.Practices.ServiceLocation;
using SolrNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Application
{
    public class SolrManager<T> where T : SolrEntity
    {
        private ISolrOperations<T> solr;

        public SolrManager()
        {
            solr = ServiceLocator.Current.GetInstance<ISolrOperations<T>>();
        }

        public void AddDocument(T doc)
        {
            solr.Add(doc);
            solr.Commit();
        }

        public SolrQueryResults<T> SearchSolr(string databaseName, string tableName, string query)
        {
          return solr.Query(new SolrQuery("tstdata:" + query));
        }
    }
}
